<?php
	class LinkAction extends BaseAction{
		//显示所有友情链接列表
		public function show(){
			$link = M('Link');
			//文字链接
			$textLink = $link->field('webname,weburl')
							->where('type = 1 and state = 1')
							->select();
			$this->assign('textLink',$textLink);
			//图片链接
			$logoLink = $link->field('webname,weburl,logourl')
							->where('type = 2 and state = 1')
							->select();
			$this->assign('logoLink',$logoLink);
			$this->display();
		}
		
		//申请加入友情链接页面
		public function add(){
			$this->display();
		}
		
		public function insert(){
			if($_SESSION['verify'] != md5($_POST['verify'])) {
				$this->error('验证码错误！');
				exit();
			}
			$link = D('Link');
			if($link->create()){
				if($link->add()){
					$this->success('恭喜申请友情链接成功！等待管理员审核！');
				}else{
					$this->error('申请友情链接失败！');
				}
			}else{
				$this->error($link->getError());
			}
		}
	}

?>